[LWDM] refactor(LIVE-29443): extract swap transaction status common logic#18862
Conversation
|
Web Tools Build Status
|
There was a problem hiding this comment.
Pull request overview
This PR refactors swap transaction status logic in @ledgerhq/live-common by extracting the former exchange/transactionStatus implementation into a new exchange/swapTransactionStatus module, while keeping the legacy public import paths working via package.json export mappings.
Changes:
- Move/centralize swap transaction status primitives (API fetch, params parsing, controller logic, types) under
exchange/swapTransactionStatus. - Add shared hook + display view-model helpers (and tests) to support desktop/mobile UI parity work in the stacked PRs.
- Preserve existing
exchange/transactionStatus/*consumer import paths viatypesVersions+exportsremapping.
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| libs/ledger-live-common/src/wallet-api/Exchange/transactionStatus/getTransactionStatus.ts | Update internal imports to use the new swapTransactionStatus module. |
| libs/ledger-live-common/src/wallet-api/Exchange/transactionStatus/getTransactionStatus.test.ts | Update mocks/imports for the moved fetch implementation. |
| libs/ledger-live-common/src/exchange/transactionStatus/index.ts | Remove legacy barrel (now replaced by export remapping). |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/types.ts | Add shared param parsing/result types for swap status deeplinks. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/transactionStatus.ts | New barrel to re-export swap transaction status building blocks. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/status/statusValues.ts | Add canonical isTransactionStatusValue helper sourced from wallet-api enum. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/status/statusController.ts | Shared controller state machine + leg status resolution logic. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/status/statusController.test.ts | Adjust imports / validate controller behavior. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/params/parseParams.ts | Parse + sanitize deeplink params (swapId/provider/redirectUrl). |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/params/parseParams.test.ts | Add unit tests for redirect sanitization + parsing behavior. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/index.ts | Public-ish module entry exporting transactionStatus/display/hook. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/hooks/useSwapTransactionStatusController.ts | New shared hook to poll status + sync accounts and emit view-model. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/hooks/useSwapTransactionStatusController.test.tsx | Add tests covering polling retry/stop, auto-redirect, leg status updates. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/history/fromSwapOperation.ts | Move/retarget history-to-params mapping to new module. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/history/fromSwapOperation.test.ts | Update imports for moved history mapping. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/display/index.ts | New shared display helpers + useSwapTransactionStatusDisplayViewModel. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/display/display.test.ts | Add unit tests for display formatting + explorer URL resolution. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/api/fetchSwapStatus.ts | Move fetch wrapper to new module path. |
| libs/ledger-live-common/src/exchange/swapTransactionStatus/api/fetchSwapStatus.test.ts | Update mocks/imports for moved fetch wrapper. |
| libs/ledger-live-common/package.json | Add exports + typesVersions remaps to preserve legacy exchange/transactionStatus/* paths. |
| libs/ledger-live-common/.unimportedrc.json | Update unimported ignores + normalize some JSON formatting. |
| .changeset/mobile-swap-status-parity.md | Changeset for the extracted shared swap status logic. |
Rsdoctor Bundle Diff AnalysisFound 7 projects in monorepo, 7 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 desktop-mainPath:
📁 desktop-preloaderPath:
📁 desktop-rendererPath:
📁 desktop-webviewDappPreloaderPath:
📁 desktop-webviewPreloaderPath:
📁 desktop-workersPath:
📁 mobilePath:
Generated by Rsdoctor GitHub Action |
877a492 to
05b0e6d
Compare
Justkant
left a comment
There was a problem hiding this comment.
LGTM but would be good to cleanup the test file from the react 19 globalThis hack if possible
05b0e6d to
5f88a15
Compare
5f88a15 to
8ecbdde
Compare
|


Jira: https://ledgerhq.atlassian.net/browse/LIVE-29443
Summary
@ledgerhq/live-common/exchange/swapTransactionStatus.exchange/transactionStatus/*package import paths through explicit aliases.Review Scope
@ledgerhq/ptxforlibs/ledger-live-common/src/exchange.@ledgerhq/coin-integrationforlibs/ledger-live-common/src/wallet-apiimport changes.Validation
@ledgerhq/live-commonswap status Jest tests passed.pnpm --filter @ledgerhq/live-common unimportedpassed.pnpm --filter @ledgerhq/live-common typecheckpassed.pnpm build:llcpassed.Stack (managed by stac-man)